﻿@using MvcForum.Web.Application
@model MvcForum.Web.Areas.Admin.ViewModels.ManageUsersPointsViewModel

@{
    ViewBag.Title = "Manage User Points";
}

<div class="backbutton">
    <a href="@Url.Action("Edit", new {id = Model.User.Id})" class="btn-mvc-green">&lt;&lt; Back</a>
</div>

<div class="panel">
    <div class="panel-heading">
        <h5>
            Show all points for @Model.User.UserName
        </h5>
    </div>
    <div class="panel-content">
        <div role="tabpanel">

            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active">
                    <a href="#points" aria-controls="points" role="tab" data-toggle="tab">
                        All Points
                    </a>
                </li>
                <li role="presentation">
                    <a href="#addpoints" aria-controls="addpoints" role="tab" data-toggle="tab">
                        Add Points
                    </a>
                </li>
            </ul>

            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="points">
                    <div class="moderatepanel">

                        @if (Model.AllPoints.Any())
                        {
                            <div class="tablescroll">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>
                                                Amount
                                            </th>
                                            <th>
                                                For
                                            </th>
                                            <th>
                                                Notes
                                            </th>
                                            <th>
                                                Awarded On
                                            </th>
                                            <th>
                                                
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var point in Model.AllPoints)
                                        {
                                            <tr>
                                                <td class="pointsamount">
                                                    <span class="badge">@point.Points</span>
                                                </td>
                                                <td class="pointsfor">
                                                    @point.PointsFor.ToString()
                                                </td>
                                                <td class="pointsnotes">
                                                    @point.Notes
                                                </td>
                                                <td class="pointsawardedon">
                                                    @DatesUi.GetPrettyDate(point.DateAdded.ToString())
                                                </td>
                                                <td class="pointsremove">
                                                    @using (Html.BeginForm("RemovePoints", "Account", FormMethod.Post))
                                                    {
                                                        @Html.AntiForgeryToken()
                                                        <input data-val="true" data-val-required="The pointToRemove field is required." id="PointToRemove" name="PointToRemove" type="hidden" value="@point.Id">
                                                        <button type="submit" class="removepoints btn-mvc-green">Remove</button>
                                                    }                                                    
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>
                        }
                        else
                        {
                            <p>This user does not have any points</p>
                        }

                    </div>

                </div>
                <div role="tabpanel" class="tab-pane" id="addpoints">
                    <div class="moderatepanel">

                        <p>Add points to this User</p>
                        @using (Html.BeginForm("ManageUserPoints", "Account", FormMethod.Post))
                        {
                            @Html.HiddenFor(x => x.Id)
                            @Html.ValidationSummary(false)
                            @Html.AntiForgeryToken()

                            <div class="form-group">
                                @Html.LabelFor(x => x.Amount)
                                @Html.TextBoxFor(x => x.Amount, new {@class = "form-control", type = "number"})
                                @Html.ValidationMessageFor(x => x.Amount)
                            </div>

                            <div class="form-group">
                                @Html.LabelFor(x => x.Note)
                                @Html.TextBoxFor(x => x.Note, new {@class = "form-control"})
                                @Html.ValidationMessageFor(x => x.Note)
                            </div>

                            <button type="submit" class="btn btn--mvc-green">Add Manual Points</button>

                        }

                    </div>

                </div>
            </div>

        </div>
    </div>
</div>